package com.dean.redis;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 * @author dean
 */
public class RedisClient {
    private final static Logger logger = LoggerFactory.getLogger(RedisClient.class);
    // redis 操作连接池 后面再说
    // private static JedisPool jedisPool = null;
    private final static String IP="www.xyjdj.top";
    private final static Integer PORT = 6379;

    private final static String pass = "XYJdj520.";
    private final static Jedis jedis = new Jedis(IP,PORT);
    static {
        jedis.auth(pass);
        logger.info("redis connect test ");
        String res = jedis.ping();
        logger.info("redis connect successfully!  {} ",res);
    }


    public static void main(String[] args) {
        // 清空数据
        System.out.println(jedis.flushDB());
        // 判断某个键是否存在
        System.out.println(jedis.exists("username"));
        // 新增键值
        System.out.println(jedis.set("test_str_key","test_str_val"));
        System.out.println(jedis.exists("test_str_key"));
        System.out.println(jedis.set("password","123"));
        System.out.println(jedis.keys("*"));

    }

}
